package com.sk.order.controller;



import com.sk.product.api.ProductApi;
import com.sk.product.model.ProductInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/feign")
@RestController
public class FeignController {
    @Autowired
    private ProductApi productApi;

    //单个参数
    @RequestMapping("/o1")
    public String o1(Integer id){
        return productApi.p1(id);
    }

    //多个参数
    @RequestMapping("/o2")
    public String o2(@RequestParam("id")Integer id, @RequestParam("name")String name){
        return productApi.p2(id,name);
    }

    //接收对象
    @RequestMapping("/o3")
    public String o3(){
        ProductInfo productInfo = new ProductInfo();
        productInfo.setId(46);
        productInfo.setProductName("T恤");
        return productApi.p3(productInfo);
    }

    @RequestMapping("/o4")
    public String o4(){
        ProductInfo productInfo = new ProductInfo();
        productInfo.setId(46);
        productInfo.setProductName("T恤");
        System.out.println(productInfo.toString());
        return productApi.p4(productInfo);
    }
}
